import java.io.File;
import java.nio.file.Files;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;

/**
 * @version 1.0
 * @auyhor dongxin
 * @date 2020/12/9 14:57
 **/
public class StreamPractice {




    public static void main(String[] args) {
        Employee e1 = new Employee(1,23,"M","Rick","Beethovan");
        Employee e2 = new Employee(2,13,"F","Martina","Hengis");
        Employee e3 = new Employee(3,43,"M","Ricky","Martin");
        Employee e4 = new Employee(4,26,"M","Jon","Lowman");
        Employee e5 = new Employee(5,19,"F","Cristine","Maria");
        Employee e6 = new Employee(6,15,"M","David","Feezor");
        Employee e7 = new Employee(7,68,"F","Melissa","Roy");
        Employee e8 = new Employee(8,79,"M","Alex","Gussin");
        Employee e9 = new Employee(9,15,"F","Neetu","Singh");
        Employee e10 = new Employee(10,45,"M","Naveen","Jain");

        List<Employee> employees = Arrays.asList(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
        //筛选年龄大于70并且性别是M
        employees.stream().filter(Employee.ageThan70.and(Employee.genderM)).collect(Collectors.toList()).forEach(System.out::println);

        Deque stack =new ArrayDeque();
        stack.addFirst("1");
        stack.addFirst("2");
        System.out.println(stack.getFirst());

    }
}

class Employee{
    int id;
    int age;
    String gender;
    String firstName;
    String lastName;
    public static Predicate<Employee> ageThan70= e-> e.age>70;
    public static Predicate<Employee> genderM= employee -> employee.gender.equals("M");

    public Employee(int id, int age, String gender, String firstName, String lastName) {
        this.id = id;
        this.age = age;
        this.gender = gender;
        this.firstName = firstName;
        this.lastName = lastName;
    }

    public Employee() {
    }

    @Override
    public String toString() {
        return "Emplyee{" +
                "id=" + id +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", firstName='" + firstName + '\'' +
                ", lastName='" + lastName + '\'' +
                '}';
    }
}
